package com.esm.sm800.sm800floating;

import com.esm.sm800.R;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class GlobalUtil extends Activity {
    public static final String KEY_LANGUAGE = "sm800_language";
    public static final String KEY_COUNTRY = "sm800_country";

    public static final String PREFS_NAME = "MySharedPref";
    public static String Key_hasdataupload_swtich = "hasdatauploadswitch";
    public static boolean ishasdataupload_swtich = false;
    public static String Key_ftpserverip = "ftpserverip";
    public static String Key_ftpserveruser = "ftpserveruser";
    public static String Key_ftpserverpass = "ftpserverpass";

    public static String Key_ftpserverip_value = "ftpserverip";
    public static String Key_ftpserveruser_value = "ftpserveruser";
    public static String Key_ftpserverpass_value = "ftpserverpass";

    // 操作视频的路径
    public static final String _zh_HelpMp3Path = "/mnt/sdcard/Download/sm800help_zh.mp4"; // 中文
    public static final String _en_HelpMp3Path = "/mnt/sdcard/Download/sm800help_en.mp4"; // 英文
    public static final String _vi_HelpMp3Path = "/mnt/sdcard/Download/sm800help_en.mp4"; // 越南文

    public static String getCurrentLanguage(Context context) {
        Locale locale = context.getResources().getConfiguration().locale;
        return locale.getLanguage();
    }

    public static String getCurrentDate()
    {
        Date currentDate = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        return formatter.format(currentDate);
    }

    public static void getFTPLogin(Context context)
    {
        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        Key_ftpserverip_value = prefs.getString(Key_ftpserverip, "");
        Key_ftpserveruser_value = prefs.getString(Key_ftpserveruser, "");
        Key_ftpserverpass_value = prefs.getString(Key_ftpserverpass, "");
    }

    public static void getDatauploadSwitch(Context context)
    {
        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        ishasdataupload_swtich = prefs.getBoolean(GlobalUtil.Key_hasdataupload_swtich, false);
    }

    public static void setDatauploadSwitch(Boolean ishasdataupload)
    {
        ishasdataupload_swtich = ishasdataupload;
    }
}
